package singleStackProgrammingQuizSubmission

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method("GET")
        url(value(producer("/api/single-stack-programming-quiz-submissions/1")
                , consumer(regex("/api/single-stack-programming-quiz-submissions/\\d+"))))
    }
    response {
        status(200)
        body("""
            {
            "id":1,
            "assignmentId":1,
            "quizId":1,
            "userId":1,
            "userAnswer":"http://github.com/test/test",
            "submitTime":1,
            "status":2,
            "result":"SUCCESS",
            "answerBranch":"master",
            "buildNumber":1,
            "commitId":1
        }
        """)
        bodyMatchers {
            jsonPath('$.id', byRegex(number()))
            jsonPath('$.assignmentId', byRegex(number()))
            jsonPath('$.quizId', byRegex(number()))
            jsonPath('$.userId', byRegex(number()))
            jsonPath('$.userAnswer', byRegex("[\\s\\S]+"))
            jsonPath('$.submitTime', byRegex("[\\s\\S]+"))
            jsonPath('$.status', byRegex(number()))
            jsonPath('$.result', byRegex("[\\s\\S]+"))
            jsonPath('$.answerBranch', byRegex("[\\s\\S]+"))
            jsonPath('$.buildNumber', byRegex(number()))
            jsonPath('$.commitId', byRegex(number()))
        }
        headers {
            contentType(applicationJsonUtf8())
        }
    }
}
